clear

use "C:\Users\lenovo\Desktop\WongLiangPOBE\WongLiangStudy1and2\WongLiangStudy1and2.dta" 

//treatment group order and choice option
egen time = rowtotal (time1 time2 time3 time4 time5 time6)
replace time = . if time == 0

egen timechoice = rowtotal (time1choice time2choice time3choice time4choice time5choice time6choice)
replace timechoice = . if timechoice == 0

//for all order and choice option
egen all_time = rowtotal (all_time1 all_time2 all_time3 all_time4 all_time5 all_time6)
egen all_timeagree = rowtotal (all_time1agree all_time2agree all_time3agree all_time4agree all_time5agree all_time6agree)
replace all_timeagree = . if all_time6 == 6 & all_time6agree == .

//generate interaction term of treatment and all_time
gen treatmentXalltime= treatment * all_time

//generate study 1 and 2
gen study = 0 
replace study = 1 if resist_west !=.

//gen province factor variable
xi i.province

//generate dummy variables for choice of recommended comments, netizens' comments, and skip comments. 
gen recommendeddummy = 0
replace recommendeddummy = . if treatment == 0
replace recommendeddummy = 1 if timechoice == 1
replace recommendeddummy = . if time == 6 & timechoice == .

gen netizendummy = 0
replace netizendummy = . if treatment == 0
replace netizendummy = 1 if timechoice == 2
replace netizendummy = . if time == 6 & timechoice == .

gen skipdummy = 0
replace skipdummy = . if treatment == 0
replace skipdummy = 1 if timechoice == 3
replace skipdummy = . if time == 6 & timechoice == .


// ------- Comment Viewing Trend ---------

*** Study 1 and Study 2 ********
//for treatment group analysis only - set dataset as time series and run multinomial logistic model
tsset id time
sort id time
mlogit timechoice time ini_recommended ini_netizen male age ccp edu _I* income poli_interest news_consumption frequent_use most_recent_use discussion, base(2) vce(cluster id)
estimate store m1

//for treatment group analysis only - declare dataset to be panel data and run random-effects logistic model
xtset id time
xtlogit recommendeddummy time ini_recommended ini_netizen male age ccp edu _I* income poli_interest news_consumption frequent_use most_recent_use discussion, vce(cluster id)
estimate store m2

//generate Table 2 specification 7 and 8
estout *, cells (b(star fmt(%8.3f)) se(par fmt(%8.3f))) stats(N11, fmt(%8.5g)) drop(_I*) starlevels(* 0.05 ** 0.01) style(fixed)
estimate drop *
